package com.bawei.base.view

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.ToastUtils

/**
 * Author: Jason Zhang
 * Date: 2025/4/22
 * Desc: 基础Fragment
 */
open abstract class BaseFragment<VDB : ViewDataBinding> : Fragment() {

    protected lateinit var mDataBinding: VDB

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        //获取布局代理对象
        mDataBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false)
        return mDataBinding.root
    }

    protected fun showToast(msg: String) {
        if (msg.isNullOrEmpty()){
            ToastUtils.showLong(msg)
        }
    }

    protected abstract fun getLayoutId(): Int


}